//
//  TWbStatusesManager.m
//  TencentWB
//
//  Created by kong_jinbiao on 14-5-14.
//  Copyright (c) 2014年 user. All rights reserved.
//

#import "TWbStatusesManager.h"
#import "AFHTTPSessionManager.h"

@implementation TWbStatusesManager

+(instancetype)shareInstance
{
    static TWbStatusesManager * _sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    _sharedInstance                             = [[TWbStatusesManager alloc] init];
    });

    return _sharedInstance;
}

-(void)queryStatusesHomeTimelineWithPageFlag:(NSString *)pageFlag
                                    pagetime:(NSString *)pageTime
                                      reqnum:(NSString *)reqNum
                                        type:(NSString *)type
                                 contenttype:(NSString *)contentType
                               completeBlock:(void (^) (TWbHomeTimeLineOutput *outPut,NSError *error))block
{
    //入参
    TWbHomeTimeLineInput *input = [[TWbHomeTimeLineInput alloc]init];
    input.m_pageflag = pageFlag;
    input.m_pagetime = pageTime;
    input.m_reqnum = reqNum;
    input.m_type = type;
    input.m_contenttype = contentType;
    NSDictionary *dic = [input paramsDicForGetRequest];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    [manager GET:@"statuses/home_timeline"
      parameters:dic
         success:^(NSURLSessionDataTask *task, id responseObject)
    {
        TWbHomeTimeLineOutput *outPut = [[TWbHomeTimeLineOutput alloc]init];
        [outPut parseDataWithDic:responseObject];
        if(block)
        {
            block(outPut,nil);
        }
        
    }
         failure:^(NSURLSessionDataTask *task, NSError *error)
    {
        block(nil,error);
        
    }];
}
@end
